package cn.thank.service;

import java.util.Date;
import java.util.List;
import java.util.Random;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.thank.anno.AccountAnno;
import cn.thank.dao.UserDao;
import cn.thank.model.UseAccount;

@Service
public class UserService implements IUserService {
	@Autowired
	private UserDao userDao;
	
	@AccountAnno(method = "新增")
    public int add(){
		// 生成随机数，作为响应时间
		int max=3000;
        int min=1000;
        Random random = new Random();
        int responsetime = random.nextInt(max)%(max-min+1) + min;
		try {
			Thread.sleep(2000L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        System.out.println("----service新增方法----");
        return responsetime;
    }
	
	@AccountAnno(method = "修改")
    public int update(){
		// 生成随机数，作为响应时间
		int max=3000;
        int min=1000;
        Random random = new Random();
        int responsetime = random.nextInt(max)%(max-min+1) + min;
		try {
			Thread.sleep(2000L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("----service修改方法----");
        return responsetime;
        
    }
	
	public List<UseAccount> getAll(){
		return userDao.getAll();
	}
	
	public List<UseAccount> queryByPage(int currentPage){
		return userDao.queryByPage(currentPage);
	}
	
	public List<UseAccount> getByLimitedtime(Date limitedtime){
		return userDao.getByLimitedtime(limitedtime);
	}
	
}